package com.dw.etl.core.service;

import com.dw.etl.common.vo.PaginationVO;
import com.dw.etl.core.api.EtlJbService;
import com.dw.etl.core.bean.model.EtlJb;
import com.dw.etl.core.mapper.EtlJbMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * etlJb服务实现类
 * Created by hozeData on 2021/05/24.
 */
@Service
@Transactional
public class EtlJbServiceImpl implements EtlJbService{

    private static final Logger LOGGER = LoggerFactory.getLogger(EtlJbServiceImpl.class);

    @Autowired
    private EtlJbMapper etlJbMapper;

    @Override
    public int insert(EtlJb etlJb) {
        return etlJbMapper.insert(etlJb);
    }

    @Override
    public int insertSelective(EtlJb etlJb)  {
        return etlJbMapper.insertSelective(etlJb);
    }

    @Override
    public int deleteById(String idJb)  {
        return etlJbMapper.deleteByPrimaryKey(idJb);
    }

    @Override
    public int updateByIdSelective(EtlJb etlJb)  {

        return etlJbMapper.updateByPrimaryKeySelective(etlJb);
    }

    @Override
    public int updateById(EtlJb etlJb)  {
        return etlJbMapper.updateByPrimaryKey(etlJb);
    }

    @Override
    public EtlJb getById(String idJb)  {
        return etlJbMapper.selectByPrimaryKey(idJb);
    }

    @Override
    public List<EtlJb> findByModel(EtlJb etlJb)  {
        return etlJbMapper.findByModel(etlJb);
    }

    @Override
    public PaginationVO<EtlJb> findPageByModel(EtlJb etlJb, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<EtlJb> quesList = etlJbMapper.findByModel(etlJb);
        PageInfo<EtlJb> pageInfo = new PageInfo<>(quesList);
        PaginationVO<EtlJb> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }





}
